<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ include file="/page/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%@ include file="/adapter/adapter-bootstrap.jsp" %>
</head>
<script type="text/javascript">

	function rowClickAfter(rowIndex,tradeId) {
		var  arrId = document.getElementsByName("check");
		arrId[rowIndex -1 ].checked=true;	
	}

	//新增
	function doAddVersion(){
		window.location.href="${ctx}/appVersion/JumpAddVersion";
	}
	
	function deleteVersion(){
		if(versionId!=""){
			if(p_del()){	
	    $.ajax({
	        url:"${ctx}/appVersion/deleteVersion?versionId="+versionId+"&appId="+appId,
	        type: "POST",      
	        dataType:"json",
	        async: false,
	        success: function(data) {
	        	if(data.flag>0){
		            alert("删除成功！");	
		            window.location.reload();
	        	}
	/* 	          $.each(data, function(index, element) {
	             window.location.reload();
	          }); */
	        },
	        error: function() {
	          alert("error");
	        }
	      });
		   }
		}else{
			alert("请先选择要删除的数据！");
		}
	}
	
	
	function p_del() { 
		var msg = "您真的确定要删除吗？\n\n请确认！"; 
		if (confirm(msg)==true){ 
		return true; 
		}else{ 
		return false; 
		} 
	}

	function viewAppQrcode(){
		if(versionId!=""){
			JLUtil.woInCenterEx('${ctx}/appVersion/viewQrcode?versionId=' + versionId);
		} else {
			alert("请先选择要查看的版本！");
		}
	}
</script>
<body>
<br>
			<div class="op-btn">
				<input type="button" class="btn btn-default" value="创建版本" onclick="doAddVersion()"/>
				<input type="button" class="btn btn-default" value="删除版本" onclick="deleteVersion()"/>
				<input type="button" class="btn btn-default" value="二维码" onclick="viewAppQrcode()"/>
			</div>	
<macms:table dataListName="avList" pageMode="true" >
	<macms:html id="ch" label="选择" innerHtml="<input type=\"radio\" name=\"check\" value=\"15\">"></macms:html>
	<macms:text id="app_id" label="应用编号"></macms:text>
	<macms:text id="app_version_id" label="应用版本号"></macms:text>
	<macms:text id="app_version_date" label="版本发布日期"></macms:text>
	<macms:text id="app_last_version_id" label="上一版本号"></macms:text>
	<macms:text id="app_update_url" label="版本升级地址"></macms:text>
	<macms:text id="app_file_size" label="升级包大小(M)"></macms:text>
	<macms:text id="app_file_hash" label="升级包hash码"></macms:text>
	<macms:text id="is_must_update" label="是否必须升级" dictname="STD_YN"></macms:text>
</macms:table>
	<script language="javascript">
	    var preRow = null;
	    var appId="";
   	    var versionId="";
		$('tbody tr').bind('click', function() {
	
			var rowIndex = $(this).prevAll().length+1;
			if(rowIndex <1) return;
			
			if(preRow != null){
				preRow.removeClass("active");
			}
			$(this).addClass("active");
			preRow = $(this);
			
			appId=$(this).find("td").eq(1).text();
			versionId=$(this).find("td").eq(2).text();
			// 行单击后事件(传入行号，页面标识)
			rowClickAfter(rowIndex,
					$(this).find("td").eq(1).text());
		});
	</script>
</body>
</html>
